#ifndef __MOTOR_DRI_H
#define __MOTOR_DRI_H

#include "stm32f0xx.h"

#define  RAMP_MODALITY 1

#define ORBITAL_SPEED_MAX 108
#define SLOW_THRESHOLD 	80
#define DELAY_M_SPEED			97//91
#define THRESHOLD(X)	speed_calculat(X)
#define SLOW_SPEED_THRESHOLD	34
#define SLOW_MULTIPLE	25

#define VIDEO_MODE	1
#define DELAY_MODE	2
#define AB_SET		4
#define STOP_MOTION	5
#define YUN_VIDEO_MODE	3
#define YUN_TIME_LAPSE	7
#define YUN_DRAW_FRAMES	5
#define DRAW_MODE		3
#define TRUE	1
#define FLASE	0

#define INIT	0
#define SPEED_CALCU	1
#define PIX_PULSE	10 // 16 PULSE TO MOVE ONE HPOTO
#define BATERRY_LOW	0xFF
#define BATERRY_FULL	0XAA
#define BATERRY_CHAR	0XBB

#define SLOW_BASIC_TIME00	120
#define SLOW_BASIC_TIME11	100
#define SLOW_BASIC_TIME22	80
#define SLOW_BASIC_TIME33	60
#define SLOW_BASIC_TIME44	40
#define SLOW_BASIC_TIME55	30
#define SLOW_BASIC_TIME66	20
#define SLOW_BASIC_TIME77	15
#define SLOW_BASIC_TIME88	7

#define APP_ENTER_BACKGROUND	1 // The app runs in the background
#define APP_ENTER_FOREGROUND	2 // The app runs in the foreground


void delay_mode_init(void);
void check_bule_sataus(void);
void delay_The_countdown(void);
void get_count_down_data(void);
void voltage_change_speed(void);
void fisrt_time_begin(void);
void motor_direction_change(uint8_t dir);
void motor_exit_sleep(void);
void motor_enter_sleep(void);
void Video_move_speed_calculat(void);
void check_adjust_and_ramp(void);
void TheDir_check(void);
void time_lapse_time_check(void);
void motor_speed_set(uint32_t speedd);
uint32_t abs(uint32_t b, uint32_t a);
void delay_send_pake(uint8_t p_mode);
void slider_upORdown(uint8_t p_type);
uint32_t speed_calculat(uint8_t p_speed);
void motor_start(void);
void DelayTime_CountDown_Get(void);
void countdown_set(uint8_t type);
void Video_start(void);
uint8_t ABpoint_puslse_check(uint8_t dires);
void dir_back_reset(uint8_t dirrrr);
void compensation_for_timelapse(void);
uint32_t calculate_fast_speed_and_ramp_time(uint32_t speeds, uint8_t fast_t);
uint32_t the_time_convertTo_speed(uint32_t times);
void Send_mode_for_App(void);
void Package_dataBufer(uint8_t txsize, uint8_t *buffer);
uint8_t Fast_times_check(uint32_t times);

// auto_abpoint_check.c
void find_slow_start_setting(uint8_t sppedd);

#endif

